package com.example.constellation.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class URLContent {
    //    封装星座配对接口
    //    利用这个函数，传入星座的名称，就可以得到它所对应的URL地址
    public static String getPartnerURL(String man, String woman) {
        man = man.replace("座", "");
        woman = woman.replace("座", "");
        StringBuilder sb1 = new StringBuilder(man);
        /* 将 String 类型对象转化为 UTF-8 的形式 */
       try {
           man = URLEncoder.encode(man,"UTF-8");
           woman = URLEncoder.encode(woman,"UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
       }
        String url = "http://apis.juhe.cn/xzpd/query?men=" + man + "&women=" + woman+"&key=03ecd97524801e46b3cf3d99045026d1";
        return url;
    }

    //星座运势接口
    public static String getLuckUEL(String name){
        try {
            name = URLEncoder.encode(name,"UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        String url = "http://web.juhe.cn/constellation/getAll?consName="+name+"&type=year&key=e6bc8c0bf49a6ca65fc523736e982ba8";
        return url;
    }
}
